import time
import threading # 1.导入模块
from threading import Thread

def sing():
    for i in range(3):
        print("在唱歌")
        time.sleep(1)  # 休眠一秒钟

def dance():
    for i in range(3):
        print("在跳舞")
        time.sleep(1)

# 想要实现多任务：只能创建子线程
if __name__ == '__main__': # 入口
    # 2.创建子线程  target=sing告诉这个子线程去执行的任务叫sing 目标=函数名
    # t1 = threading.Thread(target=sing)
    # # 3.执行任务
    # t1.start()
    # t2 = threading.Thread(target=dance)
    # t2.start()
    # print(123) # 主线程结果
    t1 = Thread(target=sing)
    t1.start()
    t2 = Thread(target=dance)
    t2.start()
# start()执行任务 就绪：资源